package com.jessica.school;

import java.util.*;

class Book {
    String author;
    String name;
    int price;

    public Book(String author, String name, int price) {
        this.author = author;
        this.name = name;
        this.price = price;
    }

    @Override
    public String toString() {
        return "书的作者为：" + author + "  " + "书的名字为" + name + "  " + "书的价格为" + price;
    }

    public boolean compare(Book b) {
        return this.price < b.price;
    }
}

public class BookDemo {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);

        Book[] books = new Book[3];

        for (Book book : books) {
            System.out.println("please enter the author,the name and the price");
            book = new Book(reader.next(), reader.next(), reader.nextInt());
        }

        for (int i = 0; i < books.length; i++) {
            for (int j = 0; j < books.length - 1; j++) {
                if (books[i].compare(books[j])) {
                    Book tmp = books[j];
                    books[j] = books[i];
                    books[i] = tmp;
                }
            }
        }

        for (Book book : books) {
            System.out.println(book);
        }
    }
}
